package b2.scene.base
{
	import b2.net.*;
	import b2.player.*;
	import b2.scene.*;
	import b2.scene.camp.*;
	import b2.scene.guide.*;
	import b2.util.*;
	import b2.widget.*;
	import b2.widget.social.SocialIcon;
	import b2.widget.status.StatusBar;
	import b2.widget.vip.VipDailyGift;
	
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	
	public class BaseScene extends BasicScene
	{
		public var playerPicIcon:PlayerPicIcon;
		public var statusIcon:StatusBar;
		public var campIcon:BasicIcon;
		
		static private var instance:BaseScene;

		public function BaseScene()
		{
			super();
			//加载主界面背景
			var MainBgr:Class = ResourceHelper.getInstance().getClassByName("MainBgr");
			var mainBgr:Sprite = new MainBgr();
			mainBgr.x = 2;
			addChild(mainBgr);
			//交易站
			var TradeStop:Class = ResourceHelper.getInstance().getClassByName("TradeStop");
			var tradeStop:BaseDepartment = new BaseDepartment(TradeStop, 0);
			tradeStop.x = 327.1;
			tradeStop.y = 45;
			addChild(tradeStop);
			//科技炉
			var TechTower:Class = ResourceHelper.getInstance().getClassByName("HonourHall");
			var techTower:BaseDepartment = new BaseDepartment(TechTower, 1);
			techTower.x = 507.1;
			techTower.y = 140.3;
			addChild(techTower);
			//军部大厅
			var ArmyHeadquarters:Class = ResourceHelper.getInstance().getClassByName("ArmyHeadquarters");
			var armyHeadquarters:BaseDepartment = new BaseDepartment(ArmyHeadquarters, 2);
			armyHeadquarters.x = 170.9;
			armyHeadquarters.y = 191.2;
			addChild(armyHeadquarters);
			//我的仓库
			var Warehouse:Class = ResourceHelper.getInstance().getClassByName("Warehouse");
			var warehouse:BaseDepartment = new BaseDepartment(Warehouse, 3);
			warehouse.x = 456.1;
			warehouse.y = 330.3;
			addChild(warehouse);
			//荣誉堂
			var HonourHall:Class = ResourceHelper.getInstance().getClassByName("TechTower");
			var honourHall:BaseDepartment = new BaseDepartment(HonourHall, 4);
			honourHall.x = 65;
			honourHall.y = 36.5;
			addChild(honourHall);
			//太阳
			var Sun:Class = ResourceHelper.getInstance().getClassByName("Sun");
			var sun:BasicMc = new BasicMc(Sun);
			sun.x = 375;
			sun.y = -70;
			sun.mouseEnabled = false;
			sun.mouseChildren = false;
			addChild(sun);
			//加载用户状态图标
			statusIcon = new StatusBar(PlayerInfoManager.getInstance().myUserId);
			statusIcon.x = 135;
			statusIcon.y = 6;
			addChild(statusIcon);
			//加载用户界面
			playerPicIcon = new PlayerPicIcon(PlayerInfoManager.getInstance().myUserId);
			addChild(playerPicIcon);
			//加载右上角图标
			var topBar:TopBar = new TopBar();
			addChild(topBar);
			//加载底部图标
			var bottomBar:BottomBar = new BottomBar();
			addChild(bottomBar);
			var vipDailyGift:VipDailyGift = new VipDailyGift();
			vipDailyGift.x = 35;
			vipDailyGift.y = 180;
			addChild(vipDailyGift);
			//社交图标
			var socialIcon:SocialIcon = new SocialIcon();
			socialIcon.x = 10;
			socialIcon.y = 230;
			addChild(socialIcon);
			//出征按钮
			var CampIcon:Class = ResourceHelper.getInstance().getClassByName("CampIcon");
			campIcon = new BasicIcon(CampIcon, "出征", 0, true);
			campIcon.x = 160;
			campIcon.y = BFont.stageHeight - 75;
			addChild(campIcon);
			campIcon.addEventListener(MouseEvent.CLICK, onCampIconClick);
		}

		static public function getInstance():BaseScene
		{
			if (!instance)
				instance = new BaseScene();
			return instance;
		}

		private function onCampIconClick(event:MouseEvent):void
		{
			if (SceneManager.getInstance().currentScene is BaseScene)
			{
				SceneManager.getInstance().loadScene(CampScene.getInstance());
				GuideScene.getInstance().step++;
			}
			else if (SceneManager.getInstance().currentScene is CampScene)
			{
				SceneManager.getInstance().loadScene(BaseScene.getInstance());
			}
		}
	}
}